*(*(tempField)+next) = 0; /* put a 0 terminator on the result */
/* clean up */
DisposHandle(orderHandle);
DisposHandle(lsHandle);
/* return the result */
return tempField;
}
/* XFCN entry point */
pascal void main(paramPtr)
XCmdBlockPtr paramPtr;
{
Str255 paramStr;
/* Prepare to use globals */
RememberA0();
SetUpA4();
/* get the input container copy */
MoveHHi(paramPtr->params[0]);
HLock(paramPtr->params[0]);
theField = (Handle)paramPtr->params[0];
HLock(paramPtr->params[1]);
strcpy(paramStr,*(paramPtr->params[1]));
if (ValidStrToNum(paramStr,&sortItem)==TRUE) {
/* do the sort */
paramPtr->returnValue = DoSort();
}
else {
strcpy(paramStr,"Error in item number");
ResultIs(paramPtr,paramStr);
}
/* clean up */
HUnlock (paramPtr->params[0]);
HUnlock (paramPtr->params[1]);
RestoreA4();
return;
}
-- part contents for card part 9
----- text -----
SortFieldByItem version 1.0d1.c
Roger Brown
SortFieldByItem is an XFCN that alphabetically sorts the lines of any HyperCard container using a specified item on the line as a sort key. The inputs are a container and the number of the item to sort by. The output is a sorted copy of the container data.
This XFCN will give the same result as SortField
if there is only one item in each line and item 1 is the sort key. It assumes that the sort item will be no longer than 255 characters. If the sort item in a particular line begins with a space, it will appear first in the list, so BE CAREFUL! Similarly if a line does not have an item in the sort item position, it will appear first in the list.
Like SortField, this XFCN is quick and there is no limit to the number of lines in the container, except for the absolute limit of available memory.